package com.ruoyi.web.controller.eamp;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.eamp.domain.EampClassDate;
import com.ruoyi.eamp.service.IEampClassDateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 值班表Controller
 * 
 * @author ruoyi
 * @date 2024-08-08
 */
@RestController
@RequestMapping("/eamp/class_date")
public class EampClassDateController extends BaseController
{
    @Autowired
    private IEampClassDateService eampClassDateService;

    /**
     * 查询值班表列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_date:list')")
    @GetMapping("/list")
    public TableDataInfo list(EampClassDate eampClassDate)
    {
        startPage();
        List<EampClassDate> list = eampClassDateService.selectEampClassDateList(eampClassDate);
        return getDataTable(list);
    }

    /**
     * 导出值班表列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_date:export')")
    @Log(title = "值班表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EampClassDate eampClassDate)
    {
        List<EampClassDate> list = eampClassDateService.selectEampClassDateList(eampClassDate);
        ExcelUtil<EampClassDate> util = new ExcelUtil<EampClassDate>(EampClassDate.class);
        util.exportExcel(response, list, "值班表数据");
    }

    /**
     * 获取值班表详细信息
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_date:query')")
    @GetMapping(value = "/{dateId}")
    public AjaxResult getInfo(@PathVariable("dateId") Long dateId)
    {
        return success(eampClassDateService.selectEampClassDateByDateId(dateId));
    }

    /**
     * 新增值班表
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_date:add')")
    @Log(title = "值班表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EampClassDate eampClassDate)
    {
        return toAjax(eampClassDateService.insertEampClassDate(eampClassDate));
    }

    /**
     * 修改值班表
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_date:edit')")
    @Log(title = "值班表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EampClassDate eampClassDate)
    {
        return toAjax(eampClassDateService.updateEampClassDate(eampClassDate));
    }

    /**
     * 删除值班表
     */
    @PreAuthorize("@ss.hasPermi('eamp:class_date:remove')")
    @Log(title = "值班表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dateIds}")
    public AjaxResult remove(@PathVariable Long[] dateIds)
    {
        return toAjax(eampClassDateService.deleteEampClassDateByDateIds(dateIds));
    }
}
